<template>
  <div class="header">
    <div class="logoandinput">
      <div class="logo">
        <a href="#">网易云音乐</a>
      </div>
      <div class="back">
        <i class="iconfont icon-yuanquan-zuo"></i>
        <i class="iconfont icon-yuanquan-you"></i>
      </div>
      <div class="search">
        <input type="text" v-model="keywordsFrom.keywords" @keyup.enter="getSearch"/>
      </div>
    </div>
    <div class="login">
      <div class="login_box1" v-if="this.$store.state.loginStatus === null">
       <div class="avatar_box">
        <img src="#" alt="">
       </div>
      <button class="login_btn" @click="toLogin">未登录</button>
      </div>
      <div class="login_box2" v-else>
       <div class="avatar_box">
        <img :src="this.$store.state.profileFrom.avatarUrl" alt="">
       </div>
      <button class="login_btn el-icon-arrow-down">{{this.$store.state.profileFrom.nickname}}</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      keywordsFrom: {
        keywords: ''
      }
    }
  },
  created() {},
  methods: {
    async getSearch() {
      console.log(this.keywordsFrom.keywords)
      const { data: res } = await this.$http.post('/search/', this.keywordsFrom)
      console.log(res)
    },
    toLogin() {
      this.$router.push('/login')
    }
  }
}
</script>

<style scoped>
.header {
  background-color: #ef233c;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logoandinput {
  display: flex;
  align-items: center;
}
.logo a {
  color: #ffffff;
  font-size: 15px;
}
.logo {
  margin-left: 24px;
}
.back {
  margin: 0 14px 0 111px;
}
.icon-yuanquan-zuo {
  font-size: 25px;
  margin-right: 11px;
}
.icon-yuanquan-you {
  font-size: 25px;
}
.search input {
  outline: none;
  border: none;
  border-radius: 20px;
  width: 165px;
  height: 30px;
}
.login {
  margin-right: 24px;
  display: flex;
}
.login_box1 {
  display: flex;
}
.login_box2 {
  display: flex;
}
.login_btn {
  border: 0;
  background-color: transparent;
  color: #ffffff;
}
.avatar_box {
  height: 30px;
  width: 30px;
  border: 1px solid black;
  border-radius: 50%;
  margin-right: 10px;
}
.avatar_box img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
</style>
